<script>
import miniProgram from '@/hooks/miniProgram'
import { LOGINPATCH } from '@/constants/router/subPackages'
export default {
  onLaunch() {
    //小程序更新
    miniProgram.checkUpdate()
    // 加载系统信息
    this.$store.dispatch('SystemInfo')
  },
  onShow() {
    this.Router()
  },
  onHide() {},
  methods: {
    Router() {
      const newTime = Date.now()
      const time = (newTime - uni.getStorageSync('LoginTime')) / 3600000
      if (uni.getStorageSync('AccessToken') && time > 12) {
        uni.showModal({
          content: this.$t('login.Loginexpiration'),
          success: function () {
            uni.removeStorageSync('UserInfo')
            uni.removeStorageSync('LoginTime')
            uni.removeStorageSync('AccessToken')
            uni.navigateTo({ url: LOGINPATCH })
          }
        })
      }
      if (!uni.getStorageSync('AccessToken')) {
        uni.showModal({
          content: this.$t('login.loginTip'),
          cancelText: this.$t('login.exitCancel'),
          confirmText: this.$t('login.exitConfirm'),
          success: function () {
            uni.removeStorageSync('UserInfo')
            uni.removeStorageSync('LoginTime')
            uni.removeStorageSync('AccessToken')
            uni.navigateTo({ url: LOGINPATCH })
          }
        })
      }
    }
  }
}
</script>

<style lang="scss">
@import 'uview-ui/index.scss';
@import '@/static/style.scss';

page {
  color: $uni-text-color;
  background-color: #f1f3f5;
}
.container-wrapper {
  padding: 0 32rpx 32rpx;
}
.block-container {
  background-color: #fff;
  border-radius: 20rpx;
  padding: 24rpx;
  box-sizing: border-box;
  margin-top: 16rpx;
  /* 加点阴影 */
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

//   其实下面这个已经什么用了(在某个页面用了),可以用uview的u-line-1,u-line-2,u-line-3,u-line-4,u-line-5五个类名
.text-no-wrap {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
</style>
